import axios from "axios"

const instance = axios.create({
    baseURL: "http://localhost:3000/api"
})

instance.interceptors.request.use((config) => {
    const { token } = JSON.parse(localStorage.getItem('adminLoginInfo') || '{}')
    if (token) config.headers.Authorization = `Bearer ${token}`
    return config
})

instance.interceptors.response.use((response) => {
    return response
}, (error) => {
    // 状态码!=200 
    // error.response.status
    return Promise.reject(error)
})
export default instance